<?php

namespace App\Http\Controllers\API;

use App\Models\Subject;

class SubjectsController extends Controller
{
    public function index()
    {
        $model = Subject::when(request('school_id'),function ($q) {
            $q->whereHas('schools', function ($query) {
                $query->where('schools.id', request('school_id'));
            });
        })
            ->paginate();

        return \Response::success($model);
    }
}
